package cn.xiongxf.feignclient;

import cn.xiongxf.User;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

@Component  // 交给Spring容器管理
public class UserFeignClientFallbackFactory implements FallbackFactory<UserService> {
    @Override
    public UserService create(Throwable throwable) {
        return new UserService() {
            @Override
            public User getById(Long id) {
                return new User(-1L,"熔断触发！","当前服务不可用，请稍后再试！");
            }
        };
    }
}
